<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <link type="text/css" rel="stylesheet" href="css/style.css"/>
    <!--[if IE 6]>
    <script src="js/iepng.js" type="text/javascript"></script>
    <script type="text/javascript">
        EvPNG.fix('div, ul, img, li, input, a');
    </script>
    <![endif]-->
    <script type="text/javascript" src="js/jquery-1.11.1.min_044d0927.js"></script>
    <script type="text/javascript" src="js/jquery.bxslider_e88acd1b.js"></script>

    <script type="text/javascript" src="js/jquery-1.8.2.min.js"></script>
    <script type="text/javascript" src="js/menu.js"></script>

    <script type="text/javascript" src="js/select.js"></script>

    <script type="text/javascript" src="js/lrscroll.js"></script>

    <script type="text/javascript" src="js/iban.js"></script>
    <script type="text/javascript" src="js/fban.js"></script>
    <script type="text/javascript" src="js/f_ban.js"></script>
    <script type="text/javascript" src="js/mban.js"></script>
    <script type="text/javascript" src="js/bban.js"></script>
    <script type="text/javascript" src="js/hban.js"></script>
    <script type="text/javascript" src="js/tban.js"></script>

    <script type="text/javascript" src="js/lrscroll_1.js"></script>

    <script type="text/javascript" src="js/axios.min.js"></script>
    <script type="text/javascript" src="js/vue.min.js"></script>

    <title>尤洪</title>
</head>
<body>
<!--Begin Header Begin-->
<div class="soubg">
    <div class="sou">
        <span class="fr">
        	<span class="fl">你好，请<a href="Login.html">登录</a>&nbsp; <a href="Regist.html" style="color:#ff4e00;">免费注册</a>&nbsp; </span>
            <span class="fl">|&nbsp;关注我们：</span>
            <span class="s_sh"><a href="#" class="sh1">新浪</a><a href="#" class="sh2">微信</a></span>
            <span class="fr">|&nbsp;<a href="#">手机版&nbsp;<img src="images/s_tel.png" align="absmiddle"/></a></span>
        </span>
    </div>
</div>
<!--End Header End-->
<!--Begin Login Begin-->
<div class="log_bg">
    <div class="top">
        <div class="logo"><a href="Index.html"><img src="images/logo.png"/></a></div>
    </div>
    <div class="regist" id="regist">
        <div class="log_img"><img src="images/l_img.png" width="611" height="425"/></div>
        <div class="reg_c">

            <table border="0" style="width:420px; font-size:14px; margin-top:20px;" cellspacing="0" cellpadding="0">
                <tr height="50" valign="top">
                    <td width="95">&nbsp;</td>
                    <td>
                        <span class="fl" style="font-size:24px;">注册</span>
                        <span class="fr">已有商城账号，<a href="Login.html" style="color:#ff4e00;">我要登录</a></span>
                    </td>
                </tr>
                <tr height="50">
                    <td align="right"><font color="#ff4e00">*</font>&nbsp;登录用户名 &nbsp;</td>
                    <td><input type="text" value="" class="l_user" v-model="loginName" @blur="hasloginName(false)"/></td>
                </tr>
                <tr height="17" v-show="err[0]">
                    <td></td>
                    <td style="color: red;font-size: 13px;" v-text="msg[0]"></td>
                </tr>
                <tr height="50">
                    <td align="right"><font color="#ff4e00">*</font>&nbsp;密码 &nbsp;</td>
                    <td><input type="password" value="" class="l_pwd" v-model="opwd" @blur="checkopwd"/></td>
                </tr>
                <tr height="17" v-show="err[1]">
                    <td></td>
                    <td style="color: red;font-size: 13px;" v-text="msg[1]"></td>
                </tr>
                <tr height="50">
                    <td align="right"><font color="#ff4e00">*</font>&nbsp;确认密码 &nbsp;</td>
                    <td><input type="password" value="" class="l_pwd" v-model="npwd" @blur="checknpwd"/></td>
                </tr>
                <tr height="17" v-show="err[2]">
                    <td></td>
                    <td style="color: red;font-size: 13px;" v-text="msg[2]"></td>
                </tr>
                <tr height="50">
                    <td align="right"><font color="#ff4e00">*</font>&nbsp;真实姓名 &nbsp;</td>
                    <td><input type="text" value="" class="l_mem" v-model="userName" @blur="checkUserName"/></td>
                </tr>
                <tr height="17" v-show="err[3]">
                    <td></td>
                    <td style="color: red;font-size: 13px;" v-text="msg[3]"></td>
                </tr>
                <tr height="50">
                    <td align="right"><font color="#ff4e00">*</font>&nbsp;性别 &nbsp;</td>
                    <td>
                        <input type="radio" name="sex" value="1" v-model="sex" @click="checksex(true)"/>
                        <label>男</label>
                        <input type="radio" name="sex" value="0" v-model="sex" @click="checksex(true)"/>
                        <label>女</label>
                    </td>
                </tr>
                <tr height="17" v-show="err[4]">
                    <td></td>
                    <td style="color: red;font-size: 13px;" v-text="msg[4]"></td>
                </tr>
                <tr height="50">
                    <td align="right"><font color="#ff4e00">*</font>&nbsp;身份证号 &nbsp;</td>
                    <td><input type="text" value="" class="l_num" v-model="identityCode" @blur="checkIdentityCode"/>
                    </td>
                </tr>
                <tr height="17" v-show="err[5]">
                    <td></td>
                    <td style="color: red;font-size: 13px;" v-text="msg[5]"></td>
                </tr>
                <tr height="50">
                    <td align="right"><font color="#ff4e00">*</font>&nbsp;邮箱 &nbsp;</td>
                    <td><input type="text" value="" class="l_email" v-model="email" @blur="hasEmail(false)"/></td>
                </tr>
                <tr height="17" v-show="err[6]">
                    <td></td>
                    <td style="color: red;font-size: 13px;" v-text="msg[6]"></td>
                </tr>
                <tr height="50">
                    <td align="right"><font color="#ff4e00">*</font>&nbsp;手机 &nbsp;</td>
                    <td><input type="text" value="" class="l_tel" v-model="tel" @blur="checktel"/></td>
                </tr>
                <tr height="17" v-show="err[7]">
                    <td></td>
                    <td style="color: red;font-size: 13px;" v-text="msg[7]"></td>
                </tr>
                <tr>
                    <td>&nbsp;</td>
                    <td style="font-size:12px; padding-top:20px;">
                	<span style="font-family:'宋体';" class="fl">
                    	<label class="r_rad"><input type="checkbox" v-model="checked"
                                                    @click="checkagreement(true)"/></label><label class="r_txt">我已阅读并接受《用户协议》</label>
                    </span>
                    </td>
                </tr>
                <tr height="17" v-show="err[8]">
                    <td>&nbsp;</td>
                    <td style="color: red;font-size: 13px;" v-text="msg[8]"></td>
                </tr>
                <tr height="60">
                    <td>&nbsp;</td>
                    <td><input type="submit" value="立即注册" class="log_btn" @click="hasloginName(true)"/></td>
                </tr>
            </table>

        </div>
    </div>
</div>
<!--End Login End-->
<!--Begin Footer Begin-->
<div class="btmbg">
    <div class="btm">
        备案/许可证编号：蜀ICP备12009302号-1-www.dingguagua.com Copyright © 2015-2018 尤洪商城网 All Rights Reserved. 复制必究 , Technical
        Support: Dgg Group <br/>
        <img src="images/b_1.gif" width="98" height="33"/><img src="images/b_2.gif" width="98" height="33"/><img
            src="images/b_3.gif" width="98" height="33"/><img src="images/b_4.gif" width="98" height="33"/><img
            src="images/b_5.gif" width="98" height="33"/><img src="images/b_6.gif" width="98" height="33"/>
    </div>
</div>
<!--End Footer End -->
<script type="text/javascript">
    Vue.config.productionTip = false;
    var err = new Array(9).fill(false);
    var msg = new Array(9).fill(false);
    var isReturn = new Array(9).fill(false);
    const vm = new Vue({
        el: '#regist',
        data: {
            loginName: '',
            userName: '',
            opwd: '',
            npwd: '',
            email: '',
            tel: '',
            men: '',
            num: '',
            msg: msg,
            err: err,
            sex: '',
            identityCode: '',
            isReturn: isReturn,
            checked: false
        },
        methods: {
            addUser() {//添加注册用户
                var isRegist = true;
                this.checkopwd();
                this.checknpwd();
                this.checkUserName();
                this.checkIdentityCode();
                this.checktel();
                this.checksex(false);
                this.checkagreement(false);

                for (i = 0; i < this.isReturn.length; i++) {
                    if (this.isReturn[i] == false) {
                        isRegist = false;
                        break;
                    }
                }
                if (isRegist) {
                    axios({
                        url: 'index/regist',
                        method: 'post',
                        data: {
                            loginName: this.loginName,
                            userName: this.userName,
                            password: this.npwd,
                            email: this.email,
                            sex: this.sex,
                            identityCode: this.identityCode,
                            mobile: this.tel
                        }
                    }).then(rs => {
                        console.log(rs);
                        if (rs.data == 'yes') {
                            alert("注册成功！去登录吧！")
                            window.location.href = 'Login.html'
                        } else {
                            alert("注册失败！")
                        }
                    })
                }
            },
            hasloginName(flag) {//判断用户名是否存在
                this.checkLoginName();
                if(!this.isReturn[0]){
                    return false;
                }
                axios.get('index/hasLoginName', {
                    params: {
                        loginName: this.loginName
                    }
                }).then(rs => {
                    console.log(rs);
                    this.$set(this.isReturn, 0, false);
                    var er = false;
                    var ms = '';
                    if (rs.data == 'yes') {
                        er = true;
                        ms = '该登录名已存在，请重新输入';
                    } else {
                        er = false;
                        this.$set(this.isReturn, 0, true);
                        console.log(this.isReturn[0] + '测试');
                        if(flag){
                            this.hasEmail(true);
                        }
                    }
                    this.$set(this.err, 0, er);
                    this.$set(this.msg, 0, ms);
                })
            },
            hasEmail(flag){
                this.checkthemail();
                if(!this.isReturn[6]){
                    return false;
                }
                axios.get('index/hasEmail', {
                    params: {
                        email: this.email
                    }
                }).then(rs => {
                    console.log(rs);
                this.$set(this.isReturn, 6, false);
                var er = false;
                var ms = '';
                console.log("邮箱验证")
                console.log(rs.data);
                if (rs.data == 'yes') {
                    er = true;
                    ms = '该邮箱已被其他用户绑定';
                } else {
                    er = false;
                    this.$set(this.isReturn, 6, true);
                    console.log(this.isReturn[6] + '测试');
                    if(flag){
                        this.addUser();
                    }
                }
                this.$set(this.err, 6, er);
                this.$set(this.msg, 6, ms);
                })
            },
            isEmpty(obj) {//判断是否为空
                var regu = "^[ ]+$";
                var re = new RegExp(regu);
                if (typeof obj == "undefined" || obj == null || obj == "" || re.test(obj)) {
                    return true;
                } else {
                    return false;
                }
            },
            //身份证验证star
            checkProv(val) {//验证省份
                var pattern = /^[1-9][0-9]/;
                var provs = {
                    11: "北京",
                    12: "天津",
                    13: "河北",
                    14: "山西",
                    15: "内蒙古",
                    21: "辽宁",
                    22: "吉林",
                    23: "黑龙江 ",
                    31: "上海",
                    32: "江苏",
                    33: "浙江",
                    34: "安徽",
                    35: "福建",
                    36: "江西",
                    37: "山东",
                    41: "河南",
                    42: "湖北 ",
                    43: "湖南",
                    44: "广东",
                    45: "广西",
                    46: "海南",
                    50: "重庆",
                    51: "四川",
                    52: "贵州",
                    53: "云南",
                    54: "西藏 ",
                    61: "陕西",
                    62: "甘肃",
                    63: "青海",
                    64: "宁夏",
                    65: "新疆",
                    71: "台湾",
                    81: "香港",
                    82: "澳门"
                };
                if (pattern.test(val)) {
                    if (provs[val]) {
                        return true;
                    }
                }
                return false;
            },
            checkDate(val) {//出生日期校验
                var pattern = /^(18|19|20)\d{2}((0[1-9])|(1[0-2]))(([0-2][1-9])|10|20|30|31)$/;
                if (pattern.test(val)) {
                    var year = val.substring(0, 4);
                    var month = val.substring(4, 6);
                    var date = val.substring(6, 8);
                    var date2 = new Date(year + "-" + month + "-" + date);
                    if (date2 && date2.getMonth() == (parseInt(month) - 1)) {
                        return true;
                    }
                }
                return false;
            },
            checkCode(val) {//身份证校验码校验
                var p = /^[1-9]\d{5}(18|19|20)\d{2}((0[1-9])|(1[0-2]))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/;
                var factor = [7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2];
                var parity = [1, 0, 'X', 9, 8, 7, 6, 5, 4, 3, 2];
                var code = val.substring(17);
                if (p.test(val)) {
                    var sum = 0;
                    for (var i = 0; i < 17; i++) {
                        sum += val[i] * factor[i];
                    }
                    if (parity[sum % 11] == code.toUpperCase()) {
                        return true;
                    }
                }
                return false;
            },
            checkID(val) {//身份证校验
                if (this.checkCode(val)) {
                    var date = val.substring(6, 14);
                    if (this.checkDate(date)) {
                        if (this.checkProv(val.substring(0, 2))) {
                            return true;
                        }
                    }
                }
                return false;
            },
            //身份证验证end
            checkEmail(str) {//邮箱验证
                var re = /^(\w-*\.*)+@(\w-?)+(\.\w{2,})+$/
                if (re.test(str)) {
                    return true;
                } else {
                    return false;
                }
            },
            checkMobile(str) {//手机号验证
                var re = /^((13[0-9])|(14[5|7])|(15([0-3]|[5-9]))|(17[0-9])|(18[0,5-9]))\d{8}$/;
                if (re.test(str)) {
                    return true;
                } else {
                    return false;
                }
            },
            checkPwd(str) {//密码验证 6到16位（字母，数字）q
                var re = /^[a-zA-Z0-9]{6,16}$/;
                if (re.test(str)) {
                    return true;
                } else {
                    return false;
                }
            },
            checkName(str) {//密码验证1到25位（字母，数字）
                var re = /^[a-zA-Z0-9_-]{1,25}$/;
                if (re.test(str)) {
                    return true;
                } else {
                    return false;
                }
            },
            checkLoginName() {

                var er = false;
                var ms = '';
                if (this.isEmpty(this.loginName)) {
                    er = true;
                    ms = '登录名不能为空';
                    this.$set(this.isReturn, 0, false);
                } else if (!this.checkName(this.loginName)) {
                    er = true;
                    ms = '登录名不符合要求，登录名只能由1~25位的字母、数字、_、-组成';
                    this.$set(this.isReturn, 0, false);
                } else {
                    er = false;
                    this.$set(this.isReturn, 0, true);
                }
                this.$set(this.err, 0, er);
                this.$set(this.msg, 0, ms);
            },
            checkopwd() {
                this.$set(this.isReturn, 1, false);
                var er = false;
                var ms = '';
                if (this.isEmpty(this.opwd)) {
                    er = true;
                    ms = '密码不能为空';
                } else if (!this.checkPwd(this.opwd)) {
                    er = true;
                    ms = '密码不符合要求，密码只能由6到16位字母，数字组成';
                } else {
                    er = false;
                    this.$set(this.isReturn, 1, true);
                }
                this.$set(this.err, 1, er);
                this.$set(this.msg, 1, ms);
            },
            checknpwd() {
                this.$set(this.isReturn, 2, false);
                var er = false;
                var ms = '';
                if (this.isEmpty(this.npwd)) {
                    er = true;
                    ms = '密码不能为空';
                } else if (!this.checkPwd(this.npwd)) {
                    er = true;
                    ms = '密码不符合要求，密码只能由6到16位字母，数字组成';
                } else if (this.opwd != this.npwd) {
                    er = true;
                    ms = '两次输入的密码不一致';
                } else {
                    er = false;
                    this.$set(this.isReturn, 2, true);
                }
                this.$set(this.err, 2, er);
                this.$set(this.msg, 2, ms);
            },
            checkUserName() {
                this.$set(this.isReturn, 3, false);
                var er = false;
                var ms = '';
                if (this.isEmpty(this.userName)) {
                    er = true;
                    ms = '真实姓名不能为空';
                } else {
                    er = false;
                    this.$set(this.isReturn, 3, true);
                }
                this.$set(this.err, 3, er);
                this.$set(this.msg, 3, ms);
            },
            checkIdentityCode() {
                this.$set(this.isReturn, 5, false);
                var er = false;
                var ms = '';
                if (this.isEmpty(this.identityCode)) {
                    er = true;
                    ms = '身份证号不能为空';
                } else if (!this.checkID(this.identityCode)) {
                    er = true;
                    ms = '身份证号输入错误';
                } else {
                    er = false;
                    this.$set(this.isReturn, 5, true);
                }
                this.$set(this.err, 5, er);
                this.$set(this.msg, 5, ms);
            },
            checkthemail() {
                this.$set(this.isReturn, 6, false);
                var er = false;
                var ms = '';
                if (this.isEmpty(this.email)) {
                    er = true;
                    ms = '邮箱号不能为空';
                } else if (!this.checkEmail(this.email)) {
                    er = true;
                    ms = '邮箱号输入错误';
                } else {
                    er = false;
                    this.$set(this.isReturn, 6, true);
                }
                this.$set(this.err, 6, er);
                this.$set(this.msg, 6, ms);
            },
            checktel() {
                this.$set(this.isReturn, 7, false);
                var er = false;
                var ms = '';
                if (this.isEmpty(this.tel)) {
                    er = true;
                    ms = '手机号不能为空';
                } else if (!this.checkMobile(this.tel)) {
                    er = true;
                    ms = '手机号输入错误';
                } else {
                    er = false;
                    this.$set(this.isReturn, 7, true);
                }
                this.$set(this.err, 7, er);
                this.$set(this.msg, 7, ms);
            },
            checksex(fg) {
                //判断是否选择了性别
                this.$set(this.isReturn, 4, false);
                var er = false;
                var ms = '';
                if (fg) {
                    if (this.sex != 0 && this.sex != 1) {
                        er = true;
                        ms = '请选择性别';
                    } else {
                        er = false;
                        this.$set(this.isReturn, 4, true);
                    }
                } else {
                    if (this.isEmpty(this.sex)) {
                        er = true;
                        ms = '请选择性别';
                    } else {
                        er = false;
                        this.$set(this.isReturn, 4, true);
                    }
                }
                this.$set(this.err, 4, er);
                this.$set(this.msg, 4, ms);
            },
            checkagreement(fg) {
                //判断协议是否勾选
                this.$set(this.isReturn, 8, false);
                var er2 = false;
                var ms2 = '';
                if (fg) {
                    if (this.checked) {
                        er2 = true;
                        ms2 = '请勾选同意协议';
                    } else {
                        er = false;
                        this.$set(this.isReturn, 8, true);
                    }
                } else {
                    if (!this.checked) {
                        er2 = true;
                        ms2 = '请勾选同意协议';
                    } else {
                        er = false;
                        this.$set(this.isReturn, 8, true);
                    }
                }
                this.$set(this.err, 8, er2);
                this.$set(this.msg, 8, ms2);
            }
        }

    });

    new Vue({
        el: ".soubg",
        data: {
            loginUser: "",
        },
        created() {
            axios("index/getUser").then(res => {
                this.loginUser = res.data;
            console.log(this.loginUser);
            if (this.loginUser !== '') {
                alert("已经登陆过了！");
                window.location.href = "Index.html";
            }
        })
        },
        methods: {}
    })
</script>
</body>


<!--[if IE 6]>
<script src="//letskillie6.googlecode.com/svn/trunk/2/zh_CN.js"></script>
<![endif]-->
</html>
